Now that I've streamlined the MCMC process, I am going to submit multiple chains simultaneously. This notebook will make multiple, similar config files, for broad comparison.
This may be rolled into pearce as a helper function, I haven't decided.
For rmin 0, 0.5, 1.0:
For no ab, HSAB and CorrAB emu:
Vpeak sham
Mpeak sham
HOD
HSAB HOD
In [1]:
import yaml
import copy
from os import path
import numpy as np
In [2]:
orig_cfg_fname = '/home/users/swmclau2/Git/pearce/bin/mcmc/nh_gg_sham_hsab_mcmc_config.yaml'
with open(orig_cfg_fname, 'r') as yamlfile:
orig_cfg = yaml.load(yamlfile)
In [3]:
orig_cfg
Out[3]:
In [4]:
orig_sbatch_fname = '/home/users/swmclau2/Git/pearce/bin/mcmc/nh_gg_sham_hsab_mcmc_config.sbatch'
with open(orig_sbatch_fname, 'r') as f:
lines = []
for line in f:
lines.append(line)
orig_sbatch = ''.join(lines)
In [5]:
#this will enable easier string formatting
sbatch_template = """#!/bin/bash
#SBATCH --job-name={jobname}
#SBATCH --time=8:00:00
#SBATCH -p kipac
#SBATCH -o /home/users/swmclau2/Git/pearce/bin/mcmc/config/{jobname}.out
#SBATCH --ntasks=16
###SBATCH --exclusive
module load python/2.7.13
module load py-scipystack
module load hdf5/1.10.0p1
python /home/users/swmclau2/Git/pearce/pearce/inference/initialize_mcmc.py {jobname}.yaml
python /home/users/swmclau2/Git/pearce/pearce/inference/run_mcmc.py {jobname}.yaml
"""
In [6]:
#emu fnames
# only sending out the HOD one cuz the others aren't yet finished
emu_fnames = ['/scratch/users/swmclau2/xi_gg_zheng07/PearceXiggCosmo.hdf5',\
'/scratch/users/swmclau2/xi_gg_corrab_zheng07/PearceXiggCosmoCorrAB.hdf5',
'/scratch/users/swmclau2/xi_gg_hsab_zheng07/PearceXiggHSABCosmo.hdf5']
emu_cov_fnames = ['/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_cov_v4.npy',
'/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_corrab_cov_v4.npy',
'/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_nh_emu_hsab_cov_v4.npy']
emu_names = ['HOD', 'CorrAB', 'HSAB']
In [7]:
#meas_cov = np.load('/home/users/swmclau2/Git/pearce/notebooks/meas_cov_testboxes_gg.npy')
meas_cov = np.load('/home/users/swmclau2/Git/pearce/bin/covmat/xi_gg_darksky_cov.npy')
In [8]:
# prep full covs
full_covs = []
for emu_name, emu_fname, cov_fname in zip(emu_names, emu_fnames, emu_cov_fnames):
cov = np.load(cov_fname)
full_cov = cov+meas_cov
fname = '/home/users/swmclau2/Git/pearce/notebooks/%s_full_cov.npy'%emu_name
np.savetxt(fname, full_cov)
full_covs.append(fname)
In [9]:
cpv = np.array([0.02214, 0.1175, -1, 0.9676, 3.0819, 0.6881*100, 3.04]) #darksky
cpn = ['ombh2', 'omch2', 'w0', 'ns', 'ln10As', 'H0', 'Neff']
cat_val_dict = dict(zip(cpn, cpv))
In [10]:
tmp_cfg = copy.deepcopy(orig_cfg)
directory = "/home/users/swmclau2/Git/pearce/bin/mcmc/config/"
output_dir = "/home/users/swmclau2/scratch/PearceMCMC/"
jobname_template = "VpeakSHAM_xi_gg_rmin_{rmin}_{emu_name}_fixed_cosmo"
for rmin in [None, 0.5, 1.0]:
for emu_fname, emu_name, emu_cov in zip(emu_fnames, emu_names, full_covs):
if rmin is not None:
tmp_cfg['emu']['fixed_params'] = {'z': 0.0, 'rmin':rmin}
tmp_cfg['chain']['fixed_params'].update(cat_val_dict)
tmp_cfg['emu']['training_file'] = emu_fname
tmp_cfg['data']['true_data_fname']= ['/home/users/swmclau2/Git/pearce/bin/shams/ds14b_sub_xi_gg.npy']
tmp_cfg['data']['true_cov_fname'] = [emu_cov]
tmp_cfg['chain']['nsteps'] = 20000
jobname = jobname_template.format(rmin=rmin, emu_name=emu_name)
tmp_cfg['fname'] = path.join(output_dir, jobname+'.hdf5')
with open(path.join(directory, jobname +'.yaml'), 'w') as f:
yaml.dump(tmp_cfg, f)
with open(path.join(directory, jobname + '.sbatch'), 'w') as f:
f.write(sbatch_template.format(jobname=jobname))
In [ ]: